package demo2;

// 实现多线程
// 方法二： 利用 Runnable 接口 , 重载 run 方法

class MyRunnable implements Runnable{
    @Override
    public void run() {

        while(true) {
            System.out.println(" this is runnable ");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class Test2 {
    public static void main(String[] args) throws InterruptedException {

        Runnable run=new MyRunnable();
        Thread t=new Thread(run);
        t.start();

        while(true){
            System.out.println("this is main runnable");
            Thread.sleep(1000);
        }

    }
}
